<%@ page import="cn.ecut.model.Dormitory" %>
<%@ page import="java.text.DateFormat" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: JMS
  Date: 2020/12/29
  Time: 20:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>租赁管理页面</title>
    <!-- Bootstrap Styles-->
    <link rel="stylesheet" href="../../static/bootstrap/css/bootstrap.css"/>
    <!-- FontAwesome Styles-->
    <link rel="stylesheet" href="../../static/font-awesome-4.7.0/css/font-awesome.css"/>
    <link rel="stylesheet" href="../../static/font-awesome-4.7.0/css/custom-styles.css"/>
    <link rel="stylesheet" href="../../static/css/style_x.css">
    <script src="../../static/bootstrap/jquery-3.5.1.min.js"></script>
    <script src="../../static/bootstrap/js/popper.js"></script>
    <script src="../../static/bootstrap/js/bootstrap.js"></script>

</head>

<body>
<div id="wrapper">
    <nav class="top-navbar">
        <div class="navbar-header">
            <strong class="navbar-brand">管理员功能菜单</strong>
        </div>
    </nav>
</div>

<!--/. NAV TOP  -->
<div class="row">
    <div class="col-2">

        <nav class="navbar-side" role="navigation">
            <div class="sidebar-collapse">
                <ul class="nav" id="main-menu">
                    <li class="active-menu">
                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
                             class="bi bi-caret-right" viewBox="0 0 16 16">
                            <path fill-rule="evenodd"
                                  d="M6 12.796L11.481 8 6 3.204v9.592zm.659.753l5.48-4.796a1 1 0 0 0 0-1.506L6.66 2.451C6.011 1.885 5 2.345 5 3.204v9.592a1 1 0 0 0 1.659.753z"/>
                        </svg>
                        <a href="../../pages/admin/getApplyList.jsp"><i class="fa fa-dashboard"></i> 租赁管理</a>
                    </li>
                    <li>
                        <a href="../../pages/admin/getRepairList.jsp"><i class="fa fa-desktop"></i> 报修处理</a>
                    </li>
                    <%--<li>
                        <a href="../../pages/admin/Settlement_center.jsp"><i class="fa fa-bar-chart-o"></i> 结算中心</a>
                    </li>--%>
                    <li>

                        <a href="../../pages/admin/Report_center.jsp"><i class="fa fa-qrcode"></i> 报表中心</a>
                    </li>
                    <li>
                        <a href="../../pages/admin/Central_Archives.jsp"><i class="fa fa-history"
                                                                            aria-hidden="true"></i> 档案中心</a>
                    </li>
                    <li>
                        <a href="../../pages/admin/adminLogin.jsp"><i class="fa fa-outdent" aria-hidden="true"></i> 退出登录</a>
                    </li>
                </ul>
            </div>

        </nav>
    </div>
    <!-- /. NAV SIDE  -->
    <div class="col-10" style="height: 1200px; background: #fff;">
        <div style="margin-top: 100px">
            <c:if test="${empty sessionScope.applyList}">
                <p>暂时还没有申请内容</p>
            </c:if>
            <c:if test="${not empty sessionScope.applyList}">
                <c:forEach items="${sessionScope.applyList}" var="list">
                    <c:if test="${list.state=='申请中'}">
                        <p>
                            <a class="btn btn-success w-100" data-toggle="collapse" href="#collapseExample1"
                               role="button"
                               aria-expanded="false" aria-controls="collapseExample1">
                                (未通过)单据编号：${list.number}----------用户ID：${list.userId}----------申请状态：${list.state}(单击详情)
                            </a>
                        </p>
                        <div class="collapse" id="collapseExample1">
                            <div class="card card-body">
                                <form method="post" action="/insertContract" id="pass">
                                    <label for="contract_num">单据编号</label>
                                    <input name="contract_num" id="contract_num" value="${list.number}" readonly>
                                    <br>
                                    <label for="sub_branch">支行部门</label>
                                    <input name="sub_branch" id="sub_branch" value="中国建设银行" readonly>
                                    <br>
                                    <label for="party_a">甲方名称</label>
                                    <input name="party_a" id="party_a" value="${list.applicant}" readonly>
                                    <br>
                                    <label for="party_b">已方名称</label>
                                    <input name="party_b" id="party_b" value="东华理工科技公司" readonly>
                                    <br>
                                    <label for="type_contract">合同类型</label>
                                    <input name="type_contract" id="type_contract" value="对外出租" readonly>
                                    <br>
                                    <label for="date_start">合同开始日期</label>
                                    <input name="date_start" id="date_start" value="${list.date}" readonly>
                                    <br>
                                    <label for="date_end">合同结束日期</label>
                                    <input name="date_end" id="date_end" value="${list.expireDate}" readonly>
                                    <br>
                                    <label for="award_datetime">合同签订日期</label>
                                    <input name="award_datetime" id="award_datetime" value="${list.createTime}"
                                           readonly>
                                    <br>
                                    <label for="contract_status">合同状态</label>
                                    <input name="contract_status" id="contract_status" value="生效中" readonly>
                                    <br>
                                    <label for="entry_datetime">入行时间</label>
                                    <input name="entry_datetime" id="entry_datetime" value="${list.date}" readonly>
                                    <br>
                                    <label for="price">宿舍单价</label>
                                    <input name="price" id="price" placeholder="输入单价" onpropertychange="upMoney()"
                                           oninput="upMoney()">
                                    <br>
                                    <label for="total_contract_amount">合同总金额</label>
                                    <input name="total_contract_amount" id="total_contract_amount" readonly>
                                    <br>
                                    <label for="receivable_amount">合同应收金额（含税200元）</label>
                                    <input name="receivable_amount" id="receivable_amount" readonly>
                                    <br>
                                    <input type="button" class="btn btn-primary" value="同意申请" onclick="checkSubmit()">
                                        <%--<label for="termination_datetime">合同终止日期</label>
                                        <input name="termination_datetime" id="termination_datetime" value="${list.number}" readonly>

                                        <label for="termination_reason">终止原因</label>
                                        <input name="termination_reason" id="termination_reason" value="${list.number}" readonly>

                                        <label for="termination_people">终止人</label>
                                        <input name="termination_people" id="termination_people" value="${list.number}" readonly>--%>
                                </form>
                            </div>
                        </div>
                    </c:if>
                    <c:if test="${list.state=='申请通过'}">
                        <p>
                            <a class="btn btn-danger w-100" data-toggle="collapse" href="#collapseExample2"
                               role="button"
                               aria-expanded="false" aria-controls="collapseExample2">
                                (已通过)单据编号：${list.number}----------用户ID：${list.userId}----------申请状态：${list.state}(单击详情)
                            </a>
                        </p>
                        <div class="collapse" id="collapseExample2">
                            <div class="card card-body">
                                单据编号:${list.number}
                                <br>
                                支行部门:中国建设银行
                                <br>
                                甲方名称:${list.applicant}
                                <br>
                                已方名称:东华理工科技公司
                                <br>
                                合同类型:对外出租
                                <br>
                                合同开始日期:${list.date}
                                <br>
                                合同结束日期:${list.expireDate}
                                <br>
                                合同签订日期:${list.createTime}
                                <br>
                                合同状态:${list.state}
                                <br>
                                入行时间:${list.date}
                            </div>
                        </div>
                    </c:if>
                </c:forEach>
            </c:if>
        </div>
    </div>
</div>
</body>
<script>
    function upMoney() {
        var price = document.getElementById("price").value;
        var startDate = document.getElementById("date_start").value;
        var endDate = document.getElementById("date_end").value;
        var sdate = new Date(startDate);
        var edate = new Date(endDate);
        var days = edate.getTime() - sdate.getTime();
        var day = parseInt(days / (1000 * 60 * 60 * 24));
        document.getElementById("total_contract_amount").value = day * price;
        document.getElementById("receivable_amount").value = day * price + 200;
    }

    function checkSubmit() {
        if ($("#price").val == "") {
            alert("请输入单价");
            $("#price").focus();
            return false
        }
        $("#pass").submit();
    }
</script>
</html>